﻿@model CurrencySelectorModel
@using Nop.Web.Models.Common;
@using Nop.Web.Framework.Themes;
@using Nop.Core.Infrastructure;
@using Nop.Core;
@if (Model.AvailableCurrencies.Count > 1)
{
    var webHelper = EngineContext.Current.Resolve<IWebHelper>();
    var theme = EngineContext.Current.Resolve<IThemeContext>().WorkingDesktopTheme;

    Html.AddScriptParts(String.Format("~/Themes/{0}/Content/Scripts/jquery.styleSelect.min.js", theme));
    Html.AddScriptParts(String.Format("~/Themes/{0}/Content/Scripts/jquery.jscrollpane.min.js", theme));

    var currencies = Model.AvailableCurrencies.Select(x => new SelectListItem
    {
        Text = x.Name,
        Value = webHelper.ModifyQueryString(Url.RouteUrl("ChangeCurrency", new { customercurrency = x.Id }), "returnurl=" + HttpUtility.UrlEncode(HttpContext.Current.Request.RawUrl), null),
        Selected = x.Id.Equals(Model.CurrentCurrencyId)
    });
    
    <div class="header-currencyselector">
    
        @Html.DropDownList("customerCurrency", currencies, new { onchange = "setLocation(this.value);" })

        <script type="text/javascript">

            $(document).ready(function () {


                var options = {
                    styleClass: "new_select",
                    jScrollPane: 1
                }

                $("#customerCurrency").styleSelect(options);

            });

        </script>     
    </div>
}

